<article class="cl pd-20">
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            <a href="javascript:void(0);" onclick="del_all()" class="btn btn-danger radius">
                <i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            <a href="javascript:void(0);" onclick="check_pass_all()" class="btn btn-primary radius">
                <i class="Hui-iconfont">&#xe6a7;</i> 批量审核</a>
            <a href="javascript:void(0);" onclick="check_out_all()" class="btn btn-default radius">
                <i class="Hui-iconfont">&#xe6a6;</i> 批量禁用</a>
        </span>
    </div>
    <div class="mt-10" style="min-width:1360px;">
        <table class="table table-border table-bordered table-bg">
            <thead>
                <tr class="text-c">
                    <th width="2%">
                        <input type="checkbox" name="allcheck" value="">
                    </th>
                    <th width="4%">ID</th>
                    <th width="10%">登录名</th>
                    <th width="6%">用户组</th>
                    <th width="12%">邮箱</th>
                    <th width="8%">昵称</th>
                    <th width="8%">登录次数</th>
                    <th width="12%">最后登录时间</th>
                    <th width="10%">最后登录ip</th>
                    <th width="12%">注册时间</th>
                    <th width="6%">状态</th>
                    <th width="10%">操作</th>
                </tr>
            </thead>
            <tbody>
                {foreach $list as $val}
                <tr class="text-c">
                    <td>
                        <input type="checkbox" value="{$val.userid}" name="checkbox[]">
                    </td>
                    <td>{$val.userid}</td>
                    <td>{$val.username}</td>
                    <td>{$val.groupname}</td>
                    <td>{$val.email}</td>
                    <td>{$val.nickname}</td>
                    <td>{$val.login_num}</td>
                    <td>{$val.per_time}</td>
                    <td>{$val.per_ip}</td>
                    <td>{$val.registertime}</td>
                    <td class="td-status">
                        <div class="switch size-S" data-on-label="是" data-off-label="否" data-id="{$val.userid}">
                            <input type="checkbox" {if $val.status==1}checked{/if}>
                        </div>
                    </td>
                    <td class="td-manage">
                        <a title="编辑" href="javascript:save({$val.userid});" class="btn btn-primary radius">
                            <i class="Hui-iconfont">&#xe6df;</i></a>
                        <a title="删除" href="javascript:;" onclick="del(this,'{$val.userid}')"
                            class="ml-5 btn btn-danger radius">
                            <i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td>
                </tr>
                {/foreach}
            </tbody>
        </table>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20 ">
        <span class="r">{$list->render()|raw}</span>
    </div>
</article>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    function save(id) {
        if (!id) {
            layer.msg('请选择会员')
        }

        var url = "{:url('save')}" + "?_layer=true&id=" + id

        layer_show("修改会员", url, 960);
    }

    // 批量审核用户
    function check_pass_all() {
        check_all(1);
    }

    function check_out_all() {
        check_all(0);
    }

    function check_all(status) {
        var checkbox = $('.text-c input[name="checkbox[]"]');
        var ids = new Array();
        checkbox.each(function (x) {
            if (this.checked)
                ids.push(this.value);
        })

        var length = ids.length;

        if (length == 0) {
            layer.msg('请选择要删除的选项', {
                icon: 5,
                time: 1000
            });
            return false;
        }

        layer.confirm('确认要删除选中项吗？', function (index) {
            $.post('checkAll', {
                'id': ids,
                'status': status
            }, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {
                        icon: 1,
                        time: 2000
                    });
                    window.location.reload();
                } else {
                    layer.msg(res.msg, {
                        icon: 5,
                        time: 2000
                    });
                    return false;
                }
            }, 'json');
        });
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->